package org.xx.armory.swing.builders;

import org.xx.armory.objectparser.ParsedObjectBuilder;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

public class ToolBarModelBuilder
        extends ParsedObjectBuilder<ToolBarModel>
        implements ActionRefContainer {
    private List<String> children;

    public ToolBarModelBuilder() {
        this.children = new ArrayList<>();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void addActionRef(
            String actionName
    ) {
        this.children.add(actionName);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public ToolBarModel build() {
        return new ToolBarModel(getLineInfo(), children.stream().filter(Objects::nonNull).collect(Collectors.toList()));
    }
}
